<?php

//Observerable
class mObserverable {
    private $_observer = array();

    public function register($observer){
        $this->_observer[] = $observer;
    }

    public function remove($observer){
        $key = array_search($observer, $this->_observer);
        if($key !== FALSE){
            unset($this->_observer[$key]);
        }
    }

    public function notifyObserver(){
        array_map(
            function($value){
                if($value instanceof mObserver){
                    $value->update($this);
                }
            },
            $this->_observer
        );
    }
}


interface mObserver{
    public function update($observer);
}